
  import BScroll from '@better-scroll/core'
  import Pullup from '@better-scroll/pull-up'
  import { Rate } from 'vant'
  import headss from '../../components/header/index.vue'
  import { Swiper, SwiperSlide } from 'vue-awesome-swiper'
  BScroll.use(Pullup)

  export default {
    data() {
      return {
        isPullUpLoad: false,
        data: 30,
        value:2,
        head:false,
        Nueselist:[{
          id:1,
          img:"https://lanhu.oss-cn-beijing.aliyuncs.com/pss5smk6zewqh04am7x50ulo58k0do82lo7bb39fbe-90b8-4afe-bd52-a6c9b2dabb5e"
        },{
          id:2,
          img:'https://lanhu.oss-cn-beijing.aliyuncs.com/pskk5afj8usha6qln1wzy646rqptqx625ws32512a6c-5065-42f4-81f4-bb9d3995e2ed'
        },{
          id:4,
          img:"https://lanhu.oss-cn-beijing.aliyuncs.com/pss5smk6zewqh04am7x50ulo58k0do82lo7bb39fbe-90b8-4afe-bd52-a6c9b2dabb5e"
        },{
          id:5,
          img:'https://lanhu.oss-cn-beijing.aliyuncs.com/pskk5afj8usha6qln1wzy646rqptqx625ws32512a6c-5065-42f4-81f4-bb9d3995e2ed'
        },{
          id:6,
          img:'https://lanhu.oss-cn-beijing.aliyuncs.com/psn9e7qc90jjp3zpb2a99n4jg9kd4hxv74ea226e2-f080-49e1-a307-b12827f17695'
        }],
        list:[{
          image:'https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/61a8af0c1f655f0011bb51f4/61c94cba1158630011a4e26c/16406704915125197715.png',
          name:"幼犬为什么容易得犬瘟和细小，这里显示文章标题内容，超出折行",
          dress:'丰台长丰园和顺家园底商B23-89',
          juli:'瑞派我宠我爱'
        },{
          image:'https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/61a8af0c1f655f0011bb51f4/61c94cba1158630011a4e26c/16406704926753712403.png',
          name:"犬类洁白洁牙幼犬为什么容易得犬瘟和细小",
          dress:'丰台长丰园和顺家园底商B23-89',
          juli:'瑞派我宠我爱'
        },{
          image:'https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/61a8af0c1f655f0011bb51f4/61c94cba1158630011a4e26c/16406704928180408293.png',
          name:"小型犬抗菌药浴套餐幼犬为什么容易得犬瘟和细小",
          dress:'丰台长丰园和顺家园底商B23-89',
          juli:'瑞派我宠我爱'
        },],
        swiperOptions: {
          slidesPerView: 'auto',
          // centeredSlides: true,
          touchMoveStopPropagation :true,
          // spaceBetween: 10,
          pagination: {
            el: '.swiper-pagination',
            clickable: true
          }
        },
      }
    },
    components: {
      headss,
      Swiper,
      SwiperSlide,
      [Rate.name]: Rate,
    },
    mounted() {
      this.initBscroll()
    },
    methods: {
      goto(){
        this.$router.back()
      },
      initBscroll() {
        this.bscroll = new BScroll(this.$refs.scroll, {
          pullUpLoad: true,
          probeType:3,
        })
        this.bscroll.on('scroll', (y) => {
          // console.log(y.y,'大师赛比')
          this.$refs.headtop.back(y.y)
          // if(y.y<-100){
          //   this.head = true
          // } else {
          //   this.head = false
          //   this.$refs.headtop.back(y.y)
          // }
        })
        this.bscroll.on('pullingUp', this.pullingUpHandler)
      },
      async pullingUpHandler() {
        console.log('我到底了')
        this.isPullUpLoad = true   
        await this.requestData()
        console.log(this.list,'我服了')      
        this.bscroll.finishPullUp()
        this.bscroll.refresh()  
        this.isPullUpLoad = false         
      },
      async requestData() {
        try {
          const newData = await this.ajaxGet(/* url */)
          this.list.push(...newData)   
          console.log(this.list,'你是个啥')        
        } catch (err) {
          // handle err
          console.log(err)
        }
      },
      ajaxGet(/* url */) {
       
        return new Promise(resolve => {
          setTimeout(() => {
         
            resolve([{
              image:'https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/61a8af0c1f655f0011bb51f4/61c94cba1158630011a4e26c/16406704915125197715.png',
              name:"幼犬为什么容易得犬瘟和细小，这里显示文章标题内容，超出折行",
              dress:'丰台长丰园和顺家园底商B23-89',
              juli:'瑞派我宠我爱'
            },{
              image:'https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/61a8af0c1f655f0011bb51f4/61c94cba1158630011a4e26c/16406704926753712403.png',
              name:"犬类洁白洁牙幼犬为什么容易得犬瘟和细小",
              dress:'丰台长丰园和顺家园底商B23-89',
              juli:'瑞派我宠我爱'
            },{
              image:'https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/61a8af0c1f655f0011bb51f4/61c94cba1158630011a4e26c/16406704928180408293.png',
              name:"小型犬抗菌药浴套餐幼犬为什么容易得犬瘟和细小",
              dress:'丰台长丰园和顺家园底商B23-89',
              juli:'瑞派我宠我爱'
            },])
          },1000)
        })
      }
    }
  }